/**
 * 查询条件面板
 */
$import("config");
$import("config.FormComponent");

config.ConditionPanel = function(options) {
	var cfg = {
		column: 3,     // 列数
		border: false,
		defaults: {border:false}
	};

	
	Ext.apply(cfg, options);
	
	// 获取表格配置
	var table = cfg.tableConfig;
	var formComps = [];
	for (var key in table.fields) {
		if (typeof(table.fields[key]) == 'function' || table.fields[key].queryStrategy == 'NONE')
			continue;
		var comp = new config.FormComponent(table.fields[key]);
		if (comp) {
			if (comp.length == 2) {
				// 范围查询
				formComps.push(comp[0]);
				formComps.push(comp[1]);
			} else
				formComps.push(comp);
		}
			
	}
	
	
	// 排列表单字段
	var columnItems = [];
	for (var i = 0; i < cfg.column; i ++) {
		columnItems[i] = {
			columnWidth: 1 / cfg.column,
			layout: 'form',
			items: []
		};
	}
	Ext.each(formComps, function(item, index) {
		columnItems[index % cfg.column].items.push(item);
	});
	cfg.items = [{
		 layout: 'column',
		 defaults : { border:false },
		 items: columnItems
	}];
	
	config.ConditionPanel.superclass.constructor.call(this, cfg);
}
Ext.extend(config.ConditionPanel, Ext.form.FormPanel, {
});


